package top.lyjwn.ajui.widget.botton;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import top.lyjwn.ajui.R;

/**
 * 开关按钮
 *
 * @luoyujie
 */
public class SwitchIosButton extends LinearLayout {

    private com.xuexiang.xui.widget.button.switchbutton.SwitchButton switchButton;

    public SwitchIosButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    public SwitchIosButton(Context context) {
        this(context, null);
    }

    private void init() {
        View view = LayoutInflater.from(getContext()).inflate(R.layout.widget_botton_switch_ios, this);
        switchButton = view.findViewById(R.id.sb_ios);
    }

    public void setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener onCheckedChangeListener) {
        switchButton.setOnCheckedChangeListener(onCheckedChangeListener);

    }

    public void setChecked(boolean is){
        switchButton.setChecked(is);
    }

    public void toggle(){
        switchButton.toggle();
    }
}
